<?php
        	
namespace Addons\BigWheel\Model;
use Home\Model\WeixinModel;
        	
/**
 * BigWheel的微信模型
 */
class WeixinAddonModel extends WeixinModel{
	function reply($dataArr, $keywordArr = array()) {
		$config = getAddonConfig ( 'BigWheel' ); // 获取后台插件的配置参数	
		//dump($config);
        $map ['token'] = get_token ();
        $keywordArr ['aim_id'] && $map ['id'] = $keywordArr ['aim_id'];
        $data = M ( 'bigwheel' )->where ( $map )->find ();

        // 其中token和openid这两个参数一定要传，否则程序不知道是哪个微信用户进入了系统
        $param ['token'] = get_token ();
        $param ['id'] = $data ['id'];
        $url = addons_url ( 'BigWheel://BigWheel/show', $param );

        $articles [0] = array (
            'Title' => $data ['title'],
            'Url' => $url
        );

        $now = time ();
        if ($data ['end_time'] > $now) {
            $articles [0] ['Description'] = $data ['intro'];
            $articles [0] ['PicUrl'] = ! empty ( $data ['cover'] ) ? get_cover_url ( $data ['cover'] ) : SITE_URL . '/Addons/BigWheel/View/default/Public/images/dzp-start.jpg';
        } else {
            $articles [0] ['Description'] = $data ['end_tips'];
            $articles [0] ['PicUrl'] = ! empty ( $data ['end_cover'] ) ? get_cover_url ( $data ['end_cover'] ) : SITE_URL . '/Addons/BigWheel/View/default/Public/images/end.jpg';
        }

        $this->replyNews ( $articles );
	} 

	// 关注公众号事件
	public function subscribe() {
		return true;
	}
	
	// 取消关注公众号事件
	public function unsubscribe() {
		return true;
	}
	
	// 扫描带参数二维码事件
	public function scan() {
		return true;
	}
	
	// 上报地理位置事件
	public function location() {
		return true;
	}
	
	// 自定义菜单事件
	public function click() {
		return true;
	}	
}
        	